﻿// 向当前选定帧上添加一段代码
var addCode = "\n// 以下是从Command命令中添加的代码\n";
addCode += "//此处输入代码\nfunction get_id(str:String, pos:int = 1):int\n{\n	var arr:Array = str.split(\"_\");\n	return int(arr[pos]);\n}\nfunction $(mc:MovieClip, func:Function, prefix:String, suffix:String = \"\", s:int = 1, e:int = -1 ):void\n{\n	var item:InteractiveObject;\n	var i:int\n	if(e != -1)\n	{\n		for(i = s; i <= e; i++)\n		{\n			item = mc[prefix + i + suffix];\n			func.apply(null, [item]);\n		}\n	}\n	else\n	{\n		for(i = s; item = mc[prefix + i + suffix]; i++)\n		{\n			func.apply(null, [item]);\n		}\n	}\n}\nfunction top(obj:DisplayObject):void\n{\n	obj.parent.setChildIndex(obj, obj.parent.numChildren - 1);\n}";
var frameArray = fl.getDocumentDOM().getTimeline().getSelectedFrames(); 
var frameObj = fl.getDocumentDOM().getTimeline().layers[frameArray[0]].frames[frameArray[1]].actionScript += addCode;
